<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="com.cap.bts.framework.usermgnt.constant.EmployeeStatus"%>    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>优惠券生成</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css" />
<script type="text/javascript" src="${layerPath}/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${layerPath}/layer.js"></script>
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css"/>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>

</head>
<script type="text/javascript">
$(function(){
	$("#batchName").blur(function(){
		if($("#batchName").val()==""){
			$("#batchNameErrorMessage").html("*必须输入");
		}else{
			$("#batchNameErrorMessage").html("");
		}
	});
	
		$("#startDate").blur(function(){
		if($("#startDate").val()==""){
			$("#startDateErrorMessage").html("*必须输入");
		}else{
			$("#startDateErrorMessage").html("");
		}
	});
		
		$("#endDate").blur(function(){
			if($("#endDate").val()==""){
				$("#endDateErrorMessage").html("*必须输入");
			}else{
				$("#endDateErrorMessage").html("");
			}
		})
		
});
function addCouponBatch(){
	var validateResult=false;
	if($("#batchName").val()==""){
		$("#batchNameErrorMessage").html("*必须输入");
		validateResult=true;
	}else{
		$("#batchNameErrorMessage").html("");
	}

	if($("#startDate").val()==""){
		$("#startDateErrorMessage").html("*必须输入");
		validateResult=true;
	}else{
		$("#startDateErrorMessage").html("");
	}
	if($("#endDate").val()==""){
		$("#endDateErrorMessage").html("*必须输入");
		validateResult=true;
	}else{
		$("#endDateErrorMessage").html("");
	}
	if(validateResult){
		return;
	}
	
	$.ajax({
		type:'post',
		url: '${webcontext}/crmdp/dealer/coupon/addCouponBatch',
		data : $("form").serialize(),
		success : function(data) {
			if(data){
				parent.location.href='${webcontext}/crmdp/dealer/coupon/toCouponBatch';
			}else{
				return;
			}
		}
	});
}


function closeLayer(){
	window.parent.search();
	//当你在iframe页面关闭自身时
	//var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
	//parent.layer.close(index); //再执行关闭  	
}
</script>

<body>
<div id="content">	
		<!-- wrap -->
		<div id="wrap">
		<form:form id="info_form" action="${webcontext}/crmdp/dealer/coupon/addCouponBatch" method="post" modelAttribute="dto">
		  <div class="data_div">
		  <input type="hidden" name="isBinded" value="0">
		  <input type="hidden" name="isGenerated" value="0">
					<table class="data_tab_blank">
						<tr>
							<th width="10%">市场活动名称</th>
							<td width="90%"><input id="batchName" class="form-control input-sm" name="batchName" value=""><span id="batchNameErrorMessage" style="color:red;"></span></td>
						</tr>
						<tr>
							<th width="10%">活动说明</th>
							<td width="90%"><input id="description" class="form-control input-sm" name="description"  value=""><span id="descriptionErrorMessage" style="color:red;"></span></td>
						</tr>
						<tr>
							<th width="10%">开始日期</th>
							<td width="90%"><input id="startDate"  name="startDate" class="form-control input-sm date" value=""><span id="startDateErrorMessage" style="color:red;"></span></td>
						</tr>
						<tr>
							<th width="10%">终止日期</th>
							<td width="90%"><input id="endDate"   name="endDate" class="form-control input-sm date" value=""><span id="endDateErrorMessage" style="color:red;"></span></td>
						</tr>
							</table>
							</div>
							 <div class="spliter h_10"></div>           
			     			 <div class="spliter h_5"></div> 
							<div  style="width:500px;height:50px;text-align: center">
							 	<input type="button" class="btn" onClick="addCouponBatch()" value="保存"/>
				                <input type="button" class="btn" onClick="closeLayer()" value="取消"/>
            				</div>
		</form:form>
		</div>

			
            </div>
</body>
</html>